<template>
    <bi-form ref="form">
        <bi-form-item label="名称"  >
            <bi-input type="text" v-model="form.title" required placeholder="请输入区块名称" />
        </bi-form-item>
        <bi-form-item label="分组"  >
            <block-group  v-model="form.blockgroup_id" required   ></block-group>
        </bi-form-item>
        <bi-form-item label="模型" >
            <web-model v-model="form.model_id" required type="block" ></web-model>
        </bi-form-item>
        <bi-form-item label="简介"  >
            <bi-textarea type="text" v-model="form.brief" placeholder="请输入区块简介" />
        </bi-form-item>
    </bi-form>
</template>

<script>
import blockGroup from '../field/block-group.vue';
import webModel from '../field/model.vue';
export default {
    components:{
        blockGroup,
        webModel
    },
    props:{
        item:Object
    },
    data()
    {

        let form = {
            block_id:'',
            title:'',
            brief:'',
            blockgroup_id:'',
            model_id:""
        }


        this.$assign(form,this.item);

        return {
            form
        }
    },
    methods:{
        dialogOk(){
            if (this.$refs.form.check()){
                this.$ajax({
                    url:this.$url({app:'web',controller:'admin.block',action:'save'}),
                    data:this.form,
                    success:(data)=>{
                        this.$toast('保存成功');
                        this.dialog.callback();
                        this.dialog.close();
                    }
                })
            }

            return false;
        }
    }
}
</script>